/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package draftMate;

import draftMate.player.Hitter;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author brianjob
 */
public class TeamHitterTable extends AbstractTableModel {
    private Team team;
    
    public void setTeam(Team team) {
        this.team = team;
    }

    @Override
    public int getRowCount() {
        if (team == null) {
            return 0;
        }
        return team.getNumHitters();
    }

    @Override
    public int getColumnCount() {
        return 2;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        if (team == null || team.getNumHitters() == 0) {
            return "";
        }
        if (columnIndex == 1) {
            return (String)team.getHitter(rowIndex).getPos();
        } else return team.getHitter(rowIndex).getName();
    }
    
    @Override
    public String getColumnName(int c) {
        switch(c) {
            case 0:
                return "Name";
            case 1:
                return "Pos";
            default:
                return "ERROR";
        }
    }
    
    @Override
    public Class getColumnClass(int c) {
        if (team == null) {
            return String.class;
        }
        return getValueAt(0, c).getClass();
    }  
}
